//
//  LCMineToolTableViewCell.m
//  lechuang
//
//  Created by Mr_hi on 2023/3/23.
//  Copyright © 2023 Mooyi. All rights reserved.
//

#import "LCMineToolTableViewCell.h"


@interface LCMineToolTableViewCell ()<UICollectionViewDelegateFlowLayout, UICollectionViewDataSource>

@property (weak, nonatomic) IBOutlet UICollectionView *toolView;

@end

@implementation LCMineToolTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

-(void)setToolArr:(NSArray *)toolArr {
    _toolArr = toolArr;
    [self.toolView reloadData];
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.toolArr.count;
}

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    CGFloat itemW = (ScreenW-34)/4;
    return CGSizeMake(itemW-1, 63);
}

-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    LCMineToolCollectionCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"LCMineToolCollectionCell" forIndexPath:indexPath];
    NSDictionary * dic = self.toolArr[indexPath.item];
    cell.iconView.image = [UIImage imageNamed:dic[@"icon"]];
    cell.nameLabel.text = dic[@"name"];
    return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    NSDictionary * dic = self.toolArr[indexPath.item];
    self.clickAction(dic[@"name"]);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end


//功能Cell
@interface LCMineToolCollectionCell ()


@end

@implementation LCMineToolCollectionCell

@end
